package com.yt.project.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yt.project.common.BaseResponse;
import com.yt.project.common.ResultUtils;
import com.yt.project.model.dto.bilibili.BilibiliDescQueryRequest;
import com.yt.project.model.dto.douyin.DouyinDescQueryRequest;
import com.yt.project.model.dto.douyin.DouyinQueryRequest;
import com.yt.project.model.entity.Douyin;
import com.yt.project.model.vo.DescVO;
import com.yt.project.model.vo.DouyinVO;
import com.yt.project.model.vo.TagDistVO;
import com.yt.project.service.DouyinService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/douyin")
public class DouyinController {

    @Resource
    private DouyinService douyinService;

    /**
     * 获取哔哩哔哩信息列表
     * @return
     */
    @PostMapping("/list")
    public BaseResponse<List<Douyin>> getDouyinList() {
        List<Douyin> list = douyinService.list();
        return ResultUtils.success(list);
    }

    /**
     * 分页获取
     * @param douyinQueryRequest
     * @return
     */
    @PostMapping("/page")
    public BaseResponse<Page<DouyinVO>> getDouyinPage(@RequestBody DouyinQueryRequest douyinQueryRequest) {
        long current = 1;
        long pageSize = 10;
        if (douyinQueryRequest != null) {
            current = douyinQueryRequest.getCurrent();
            pageSize = douyinQueryRequest.getPageSize();
        }
        Page<DouyinVO> douyinVOPage = douyinService.pageDouyin(douyinQueryRequest);
        return ResultUtils.success(douyinVOPage);
    }


    @PostMapping("/desc")
    public BaseResponse<DescVO> getDouyinDesc(@RequestBody DouyinDescQueryRequest douyinDescQueryRequest) {
        DescVO descVO = douyinService.getDescById(douyinDescQueryRequest.getId());
        return ResultUtils.success(descVO);
    }


    @PostMapping("/dist/tags")
    public BaseResponse<List<TagDistVO>> getTagsDist(@RequestBody DouyinDescQueryRequest douyinDescQueryRequest) {
        List<TagDistVO> tagDistVOS = douyinService.getTagsDist(douyinDescQueryRequest.getId());
        return ResultUtils.success(tagDistVOS);
    }
}
